Skip to content

Define option and optgroup base appearance rendering#12201

Open
josepharhar wants to merge 18 commits into
whatwg:mainfrom
josepharhar:optgrouprendering
Open

Define option and optgroup base appearance rendering#12201
josepharhar wants to merge 18 commits into
whatwg:mainfrom
josepharhar:optgrouprendering

Conversation

@josepharhar

@josepharhar josepharhar commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

The old text didn't explain that there is a shadow tree with an element which renders the label attribute, and that it goes away when the author provides a legend element. The UA styles for rendering the optgroup element with base appearance are still valid.

Context: #12199

(See WHATWG Working Mode: Changes for more details.)


/form-elements.html ( diff )
/rendering.html ( diff )

The old text didn't explain that there is a shadow tree with an element
which renders the label attribute, and that it goes away when the author
provides a legend element. The UA styles for rendering the optgroup
element with base appearance are still valid.

Fixes whatwg#12199

@annevk annevk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also change <optgroup>.label so it actually reflects the legend element when there is one. Seems quite strange the API would not reflect all of this. But that's probably a separate change at this point with its own tests.

Comment thread source Outdated
<span>expected</span> to contain a copy of the text in the <code>optgroup</code>'s <code
data-x="attr-optgroup-label">label</code> attribute. If the <code>optgroup</code> has a child
<code>legend</code> element, then the <span>optgroup label element</span> is not
rendered.</p></li>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use a slot with fallback for this? Does the legend element intentionally have different requirements than the button element. It can appear anywhere?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also found out today that this optgroup label element is expected to have padding?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And in Chrome min-height is set to 0 but that should probably be auto? cc @nt1m

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use a slot with fallback for this? Does the legend element intentionally have different requirements than the button element. It can appear anywhere?

It is supposed to be first, so yeah we could do slotting instead: https://html.spec.whatwg.org/multipage/form-elements.html#the-optgroup-element

I'll go ahead and make that change here, in chromium, and WPT.

I also found out today that this optgroup label element is expected to have padding?

Yes, I made it have the same style as the legend element when rendered with base appearance. If we made it a web exposed part-like pseudo-element, which would be awesome, then we could define that in the same style rule as the legend element. Since it isn't, at least not yet, I'll add a paragraph there which says what the expected styles are.

And in Chrome min-height is set to 0 but that should probably be auto? cc @nt1m

Ah, my bad I thought that 0 was the default value. I'll change it to something better like unset.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can first agree on the details? Since we’d have to change styles as well presumably. I’m not a 100% sold on either approach yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, how would you like to go about agreeing on the details?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made an attempt here: #12199 (comment)

Comment thread source Outdated
<code>option</code> <span data-x="option-base-appearance">is being rendered with base
appearance</span> and the <code>option</code>'s <code data-x="attr-option-label">label</code>
attribute is not set, then the <code>option</code> is <span>expected</span> to render all of its
children rather than by displaying its <span data-x="concept-option-label">label</span>.</p>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to describe this in terms of an internal shadow tree as well. At least without that it's not clear to me how "expected to be rendered" would impact the availability of pseudo-elements.

cc @dbaron @emilio

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I replaced this with an internal shadow tree definition

beckysiegel pushed a commit to chromium/chromium that referenced this pull request Apr 1, 2026
Apparently min-height:0 is not the initial/default value that we should
be using, so I am changing it to unset. Context:
whatwg/html#12201 (comment)

Change-Id: Id3af6326646851d31c614b0290f9feca3db5e91e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7630018
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Reviewed-by: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1608241}
@lukewarlow

lukewarlow commented Apr 10, 2026

Copy link
Copy Markdown
Member

I think we want to make it so only the first legend of an optgroup renders right? Currently chromium renders all legends, and Safari Tech Preview renders only the first.

Making the rest display: none seems reasonable (not sure if that is what Safari has done).

Though saying that fieldset currently renders all legends you give it, it just only treats the first one specially. Maybe we should still render the legends but just not give them the special styles, specifically I don't htink they should get the optgroups font-weight bolder.

@lukewarlow

lukewarlow commented Apr 10, 2026

Copy link
Copy Markdown
Member

Hmm actually I just realised that appearance auto listbox select is completely non-interopable with its handling of multiple legends. So definitely we should address that for base appearance and hopefully for auto too.

I'm happy to open a new issue if thats preferable but here's what I see.

data:text/html,<select size="3"><optgroup><legend>First</legend><legend>Second</legend><option>Option</option></optgroup></select>

Safari Firefox Chrome
image image image

Firefox I'm guessing is because they just don't have the parsing for <legend> in optgroup yet.

@josepharhar

Copy link
Copy Markdown
Contributor Author

I think we want to make it so only the first legend of an optgroup renders right?

Considering that we still render everything else that doesn't fit in the content model, I don't think we should add behavior to not render this case in particular - assuming that you're talking about base appearance, not native appearance.

Currently chromium renders all legends, and Safari Tech Preview renders only the first.

The screenshot in your second comment seems to show this, and yeah it looks to me like firefox just hasn't gotten around to implementing this yet.

@lukewarlow

Copy link
Copy Markdown
Member

It feels weird for the second one to be bold to me given it's nothing special it's just text at that point. But perhaps if it's unbold it'll look too much like an option.

Idk the safari option feels better at least for auto appearance. But I'll defer to others.

@annevk

annevk commented Apr 12, 2026

Copy link
Copy Markdown
Member

Listbox base appearance is not yet finalized, right? For listbox auto appearance I would expect "get an optgroup element's label" to determine the label. And only the option elements for the remainder. We shouldn't render all kinds of random elements there. And the same goes for the dropdown variant auto appearance.

For dropdown base appearance I think it's fine if multiple legend elements end up rendering.

@lukewarlow

Copy link
Copy Markdown
Member

Listbox base appearance is in the spec fwiw.

@josepharhar

Copy link
Copy Markdown
Contributor Author

Should I add any text to this PR which says that in native/primtive appearance only one legend or label should be rendered? Or anything else from #12199 like explicitly saying that when options and optgroups are placed outside of a select element they render their contents like a normal element?

@annevk

annevk commented Apr 15, 2026

Copy link
Copy Markdown
Member

If the aim is to fix that issue just defining the base appearance is insufficient. As customizable select introduced new features, we need to update the rendering text to account for those, including for native appearance. I would be okay with addressing the issue with several PRs, but then OP should not claim it fixes that issue.

@josepharhar

Copy link
Copy Markdown
Contributor Author

Ok, I changed the op to say that the issue is not fixed and filed bugs.

Comment thread source Outdated
<p>An <code>optgroup</code> element is <dfn data-x="optgroup-base-appearance">rendered with base
appearance</dfn> if it has an <span>ancestor</span> <code>select</code> element, and the nearest
<span>ancestor</span> <span><code>select</code>'s <code>option</code>s are being rendered with
base appearance</span>.</p>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we talking about option elements here? An optgroup can't have option element ancestors, can it? Can we reference the existing definition for nearest ancestor select element?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this in order to reuse the algorithm which determines when the elements inside a select besides the option are being rendered with base appearance: https://html.spec.whatwg.org/multipage/rendering.html#select's-options-are-being-rendered-with-base-appearance

I removed the word option from the algorithm to make that more clear. How does it look now?

Comment thread source Outdated
<p>If an <code>optgroup</code> element is not being <span
data-x="optgroup-base-appearance">rendered with base appearance</span>, then it is
<span>expected</span> to be rendered by displaying the element's <span
data-x="concept-optgroup-label">label</span>.</p>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we're not fixing this here we should add an XXX marker as this is clearly broken.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i added an XXX

Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
displaying its <span data-x="concept-option-label">label</span>.</p>
<p>If an <code>option</code> element is not being <span data-x="option-base-appearance">rendered
with base appearance</span>, then it is <span>expected</span> to be rendered by displaying the
result of <span>collect option text</span> given the <code>option</code> and true.</p>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we first have to define what it means for an option element to be rendered with base appearance as base/native appearance isn't a thing for option elements (aiui). So the same order as above for optgroup with probably the same set of comments.

If we also tackle option we need to update the PR to make that clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So should I add a <p class="XXX"> saying that option elements need their native and primitive appearance to be specified?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That probably has to happen as well then, yes.

My preferred solution would be that we just define it as part of select's native appearance, but it seems that's not possible given how Chromium does things here and maybe Gecko?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took another look and I'm not sure what the option element is missing that the optgroup element has with regards to base/native appearance in this PR. Could you elaborate on what is missing?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For optgroup we start out with defining what it means to be rendered with base appearance. For instance, we require an ancestor select (though we need to make that more precise so it deals with intermediate hr elements and the like I think).

I'm not sure that is sufficient however as these don't really have base appearance through appearance: base. It's a result of nesting, right? So I'm not sure that makes them compatible with the appearance base infra.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what we want is that some things apply universally, such as display: block and some things are conditional upon the nearest ancestor select's computed/used appearance. Because I don't think we can say that option elements themselves have any kind of appearance, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what we want is that some things apply universally, such as display: block and some things are conditional upon the nearest ancestor select's computed/used appearance.

Yes, that makes sense. I took a look at chromium, and the only UA style rule that is applied to option elements in both appearance:auto and appearance:base selects is white-space:nowrap, which maybe is another thing we just need to undo for "base appearance".

Because I don't think we can say that option elements themselves have any kind of appearance, right?

Yes, option elements don't support the appearance property. If you think we should rename this definition for options and optgroup elements, I'd be happy to rename it.

@annevk annevk Apr 26, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white-space:nowrap is currently non-standard. Does Gecko have that?

WebKit is adding display: block to both option and optgroup elements, and font-weight: bolder for optgroup, but that's it thus far (https://commits.webkit.org/311911@main). We should make the user agent style sheet reflect at least that.

As for the language, maybe something like "option/optgroup elements [with a base appearance select]" and then "with a base appearance select" is defined through the ancestor select element thingy that also handles hr elements and the like and requires the select element to have base appearance?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white-space:nowrap is currently non-standard. Does Gecko have that?

It is standardized for base appearance: https://html.spec.whatwg.org/multipage/rendering.html#:~:text=0.5em%3B-,white%2Dspace%3A%20nowrap,-%3B%0A%7D%0A%0Aselect

WebKit is adding display: block to both option and optgroup elements, and font-weight: bolder for optgroup, but that's it thus far (https://commits.webkit.org/311911@main). We should make the user agent style sheet reflect at least that.

Thanks, I see that this is about UA styles for options and optgroups when they are outside of a select element, not about base appearance. I'd be supportive of standardizing/changing those styles as long as there aren't compat issues. Maybe that's worth a separate spec issue and PR?

I added properties like white-space:nowrap to the base appearance section because I didn't think that we would actually standardize the UA styles for these elements outside of base appearance.

As for the language, maybe something like "option/optgroup elements [with a base appearance select]" and then "with a base appearance select" is defined through the ancestor select element thingy that also handles hr elements and the like and requires the select element to have base appearance?

Ok, I used the shared algorithm to find an ancestor select, and I'm still using the shared algorithm which defines when select's contents are rendered with base appearance. How does it look?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works overall. I think we should probably keep things restricted to the base appearance style sheet if they are not universal, but if we can agree on making them universal we should move them. I think that's the case for display: block and font-weight at least.

Comment thread source Outdated
not have the <code data-x="attr-option-label">label</code> attribute, or the <code
data-x="attr-option-label">label</code> is set to an empty string, then the <span>option label
element</span> is <span>expected</span> to have its <span>'display'</span> property set to
'none'.</p></li>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why not have this as a child of the slot element and then determine whether we slot things into the slot or not based on the condition of the label attribute? I thought that was the direction we were heading in.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I rewrote it to use slot assignment and a fallback instead

Comment thread source Outdated

<p>The following styles are <span>expected</span> to apply to the <span>optgroup label
element</span> when its parent <code>optgroup</code> element is being <span
data-x="optgroup-base-appearance">rendered with base appearance</span>:</p>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just make these unconditional based on select optgroup?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the shadow tree is conditional upon a select with base appearance so there is no optgroup label element without that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I made it unconditional

@annevk annevk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks better. We also discovered that display: block for option and optgroup is universal and not restricted to having a select ancestor. Should we make those changes as part of this? And optgroup has font-weight: bolder iirc.

Comment thread source Outdated
Comment thread source Outdated

<p>The following styles are <span>expected</span> to apply to the <span>optgroup label
element</span> when its parent <code>optgroup</code> element is being <span
data-x="optgroup-base-appearance">rendered with base appearance</span>:</p>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the shadow tree is conditional upon a select with base appearance so there is no optgroup label element without that.

@josepharhar

Copy link
Copy Markdown
Contributor Author

This looks better. We also discovered that display: block for option and optgroup is universal and not restricted to having a select ancestor. Should we make those changes as part of this? And optgroup has font-weight: bolder iirc.

Ok, I added these in a new css block which doesn't have any restrictions spelled out.

@annevk annevk changed the title Define optgroup base appearance rendering Define option and optgroup base appearance rendering May 11, 2026
Comment thread source Outdated
Comment thread source Outdated
Comment thread source

</div>

<pre><code class="css">@namespace "http://www.w3.org/1999/xhtml";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is lacking the usually introductory paragraph of such blocks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other CSS blocks for base appearance select elements has an introductory paragraph because there are constraints for when the CSS is supposed to apply, based on base appearance and the listbox vs dropdown state of the select element.

These styles, on the other hand, have no constraints at all. I found that other such CSS blocks which have no constraints also have no introductory paragraph:

If you still feel that this should have an introductory paragraph, what should it say?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, let's leave this for now.

Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
@annevk

annevk commented Jun 3, 2026

Copy link
Copy Markdown
Member

Thanks @josepharhar. Some final points:

  • Now that we have changed d9ce52f I think we need to state the same thing here and then specifically for the base appearance we will define what the tree looks like. cc @emilio
    • This might also necessitate more tests.
  • The note for the "option contents slot" is out of sync with the normative requirements. Maybe just remove "which happens when the author sets the label attribute." as you can find the exact condition above.
  • "It is expected to contain a copy of the text in the optgroup's label attribute." We should make this as precise as the option element counterpart. I.e., describe in terms of a Text node child.

@josepharhar

Copy link
Copy Markdown
Contributor Author

Now that we have changed d9ce52f I think we need to state the same thing here and then specifically for the base appearance we will define what the tree looks like

Thanks, I tried doing this by saying that options and optgroups have an internal shadow tree with a slot element.

I also tried to represent how options render just a text representation when they are inside a select but all children normally when outside of a select, which it seems like is the behavior that we are all implementing. Hopefully the way I am using "otherwise" outside of an algorithm here is ok, but I am happy to change it to whatever youd like.

The note for the "option contents slot" is out of sync with the normative requirements. Maybe just remove "which happens when the author sets the label attribute." as you can find the exact condition above.

Ok, I removed that text from the note.

"It is expected to contain a copy of the text in the optgroup's label attribute." We should make this as precise as the option element counterpart. I.e., describe in terms of a Text node child.

Ok, I described this in terms of a Text node child

beckysiegel pushed a commit to chromium/chromium that referenced this pull request Jun 18, 2026
Instead of setting display:none on the element which holds the label
attribute when a legend element is present, we can put the label
attribute holding element as a child of a new slot for the legend
element, so it automatically gets rendered when there is no legend
element.

The legend element is only supposed to be the first element in the
optgroup as per the content model in the HTML spec, so this patch also
enforces that by only slotting the legend element in when it is the
first child element. Allowing or using the legend element inside of
optgroups was a new feature with customizable select, so compat risk is
low.

Context: whatwg/html#12201 (comment)

There are a11y test expectations because the UA shadowroot is being
changed, but this should not be visible to ATs because the new nodes are
marked as invisible and ignored, and only appear in the internal "blink"
a11y trees as opposed to real platform trees.

Change-Id: I776fee963146abbad2028638479df7d3362c35ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7629416
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Reviewed-by: David Baron <dbaron@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1649235}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 18, 2026
Instead of setting display:none on the element which holds the label
attribute when a legend element is present, we can put the label
attribute holding element as a child of a new slot for the legend
element, so it automatically gets rendered when there is no legend
element.

The legend element is only supposed to be the first element in the
optgroup as per the content model in the HTML spec, so this patch also
enforces that by only slotting the legend element in when it is the
first child element. Allowing or using the legend element inside of
optgroups was a new feature with customizable select, so compat risk is
low.

Context: whatwg/html#12201 (comment)

There are a11y test expectations because the UA shadowroot is being
changed, but this should not be visible to ATs because the new nodes are
marked as invisible and ignored, and only appear in the internal "blink"
a11y trees as opposed to real platform trees.

Change-Id: I776fee963146abbad2028638479df7d3362c35ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7629416
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Reviewed-by: David Baron <dbaron@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1649235}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 19, 2026
Instead of setting display:none on the element which holds the label
attribute when a legend element is present, we can put the label
attribute holding element as a child of a new slot for the legend
element, so it automatically gets rendered when there is no legend
element.

The legend element is only supposed to be the first element in the
optgroup as per the content model in the HTML spec, so this patch also
enforces that by only slotting the legend element in when it is the
first child element. Allowing or using the legend element inside of
optgroups was a new feature with customizable select, so compat risk is
low.

Context: whatwg/html#12201 (comment)

There are a11y test expectations because the UA shadowroot is being
changed, but this should not be visible to ATs because the new nodes are
marked as invisible and ignored, and only appear in the internal "blink"
a11y trees as opposed to real platform trees.

Change-Id: I776fee963146abbad2028638479df7d3362c35ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7629416
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Reviewed-by: David Baron <dbaron@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1649235}
beckysiegel pushed a commit to chromium/chromium that referenced this pull request Jun 19, 2026
This reverts commit db60951.

Reason for revert: Consistent test failures on Fuchsia bots due to accessibility tree expectation mismatches.

Affected tests include: - DumpAccessibilityTreeTest.AccessibilityComboboxOptgroup - DumpAccessibilityTreeTest.AccessibilityModalDialogClosed - DumpAccessibilityTreeTest.AccessibilityModalDialogOpened - DumpAccessibilityTreeTest.AccessibilityModalDialogStack - DumpAccessibilityTreeTest.AccessibilityOptgroup ... and others.

Failure Link:
https://ci.chromium.org/ui/p/chromium/builders/ci/fuchsia-x64-cast-receiver-rel/30173/overview
https://ci.chromium.org/ui/p/chromium/builders/ci/fuchsia-arm64-cast-receiver-rel/30278/test-results

Original change's description:
> Use slot fallback to render optgroup label attr
>
> Instead of setting display:none on the element which holds the label
> attribute when a legend element is present, we can put the label
> attribute holding element as a child of a new slot for the legend
> element, so it automatically gets rendered when there is no legend
> element.
>
> The legend element is only supposed to be the first element in the
> optgroup as per the content model in the HTML spec, so this patch also
> enforces that by only slotting the legend element in when it is the
> first child element. Allowing or using the legend element inside of
> optgroups was a new feature with customizable select, so compat risk is
> low.
>
> Context: whatwg/html#12201 (comment)
>
> There are a11y test expectations because the UA shadowroot is being
> changed, but this should not be visible to ATs because the new nodes are
> marked as invisible and ignored, and only appear in the internal "blink"
> a11y trees as opposed to real platform trees.
>
> Change-Id: I776fee963146abbad2028638479df7d3362c35ac
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7629416
> Reviewed-by: Joey Arhar <jarhar@chromium.org>
> Reviewed-by: David Baron <dbaron@chromium.org>
> Commit-Queue: Joey Arhar <jarhar@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1649235}

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Iae750043c09be7dede4b8fbea417995de96ec9cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7961701
Owners-Override: Anna Sato <annasato@chromium.org>
Commit-Queue: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Anna Sato <annasato@chromium.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1649473}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 19, 2026
This reverts commit db609514c367c1018fccbea7e3e78c8036fc1ae4.

Reason for revert: Consistent test failures on Fuchsia bots due to accessibility tree expectation mismatches.

Affected tests include: - DumpAccessibilityTreeTest.AccessibilityComboboxOptgroup - DumpAccessibilityTreeTest.AccessibilityModalDialogClosed - DumpAccessibilityTreeTest.AccessibilityModalDialogOpened - DumpAccessibilityTreeTest.AccessibilityModalDialogStack - DumpAccessibilityTreeTest.AccessibilityOptgroup ... and others.

Failure Link:
https://ci.chromium.org/ui/p/chromium/builders/ci/fuchsia-x64-cast-receiver-rel/30173/overview
https://ci.chromium.org/ui/p/chromium/builders/ci/fuchsia-arm64-cast-receiver-rel/30278/test-results

Original change's description:
> Use slot fallback to render optgroup label attr
>
> Instead of setting display:none on the element which holds the label
> attribute when a legend element is present, we can put the label
> attribute holding element as a child of a new slot for the legend
> element, so it automatically gets rendered when there is no legend
> element.
>
> The legend element is only supposed to be the first element in the
> optgroup as per the content model in the HTML spec, so this patch also
> enforces that by only slotting the legend element in when it is the
> first child element. Allowing or using the legend element inside of
> optgroups was a new feature with customizable select, so compat risk is
> low.
>
> Context: whatwg/html#12201 (comment)
>
> There are a11y test expectations because the UA shadowroot is being
> changed, but this should not be visible to ATs because the new nodes are
> marked as invisible and ignored, and only appear in the internal "blink"
> a11y trees as opposed to real platform trees.
>
> Change-Id: I776fee963146abbad2028638479df7d3362c35ac
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7629416
> Reviewed-by: Joey Arhar <jarhar@chromium.org>
> Reviewed-by: David Baron <dbaron@chromium.org>
> Commit-Queue: Joey Arhar <jarhar@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1649235}

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Iae750043c09be7dede4b8fbea417995de96ec9cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7961701
Owners-Override: Anna Sato <annasato@chromium.org>
Commit-Queue: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Anna Sato <annasato@chromium.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1649473}
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Jun 23, 2026
…el attr, a=testonly

Automatic update from web-platform-tests
Use slot fallback to render optgroup label attr

Instead of setting display:none on the element which holds the label
attribute when a legend element is present, we can put the label
attribute holding element as a child of a new slot for the legend
element, so it automatically gets rendered when there is no legend
element.

The legend element is only supposed to be the first element in the
optgroup as per the content model in the HTML spec, so this patch also
enforces that by only slotting the legend element in when it is the
first child element. Allowing or using the legend element inside of
optgroups was a new feature with customizable select, so compat risk is
low.

Context: whatwg/html#12201 (comment)

There are a11y test expectations because the UA shadowroot is being
changed, but this should not be visible to ATs because the new nodes are
marked as invisible and ignored, and only appear in the internal "blink"
a11y trees as opposed to real platform trees.

Change-Id: I776fee963146abbad2028638479df7d3362c35ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7629416
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Reviewed-by: David Baron <dbaron@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1649235}

--

wpt-commits: 18d82f340a1e5c6dbc86cc45827e7da9a60e8858
wpt-pr: 60726
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Jun 23, 2026
…roup label attr", a=testonly

Automatic update from web-platform-tests
Revert "Use slot fallback to render optgroup label attr"

This reverts commit db609514c367c1018fccbea7e3e78c8036fc1ae4.

Reason for revert: Consistent test failures on Fuchsia bots due to accessibility tree expectation mismatches.

Affected tests include: - DumpAccessibilityTreeTest.AccessibilityComboboxOptgroup - DumpAccessibilityTreeTest.AccessibilityModalDialogClosed - DumpAccessibilityTreeTest.AccessibilityModalDialogOpened - DumpAccessibilityTreeTest.AccessibilityModalDialogStack - DumpAccessibilityTreeTest.AccessibilityOptgroup ... and others.

Failure Link:
https://ci.chromium.org/ui/p/chromium/builders/ci/fuchsia-x64-cast-receiver-rel/30173/overview
https://ci.chromium.org/ui/p/chromium/builders/ci/fuchsia-arm64-cast-receiver-rel/30278/test-results

Original change's description:
> Use slot fallback to render optgroup label attr
>
> Instead of setting display:none on the element which holds the label
> attribute when a legend element is present, we can put the label
> attribute holding element as a child of a new slot for the legend
> element, so it automatically gets rendered when there is no legend
> element.
>
> The legend element is only supposed to be the first element in the
> optgroup as per the content model in the HTML spec, so this patch also
> enforces that by only slotting the legend element in when it is the
> first child element. Allowing or using the legend element inside of
> optgroups was a new feature with customizable select, so compat risk is
> low.
>
> Context: whatwg/html#12201 (comment)
>
> There are a11y test expectations because the UA shadowroot is being
> changed, but this should not be visible to ATs because the new nodes are
> marked as invisible and ignored, and only appear in the internal "blink"
> a11y trees as opposed to real platform trees.
>
> Change-Id: I776fee963146abbad2028638479df7d3362c35ac
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7629416
> Reviewed-by: Joey Arhar <jarhar@chromium.org>
> Reviewed-by: David Baron <dbaron@chromium.org>
> Commit-Queue: Joey Arhar <jarhar@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1649235}

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Iae750043c09be7dede4b8fbea417995de96ec9cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7961701
Owners-Override: Anna Sato <annasato@chromium.org>
Commit-Queue: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Anna Sato <annasato@chromium.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1649473}

--

wpt-commits: eb50666fd6a4011cebe7fbf254a82a9e142e15de
wpt-pr: 60746
Comment thread source Outdated
base appearance">contents are being rendered with base appearance</span>.</p>

<p>An <code>optgroup</code> element has an internal <span>shadow tree</span> with at least one
<code>slot</code> element.</p>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just say two slots out of curiosity?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's probably what we should do longer term as we formalize shadow trees across appearance values. I guess I didn't want to make us commit to that as part of this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants